package babymall.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import babymall.dao.ICategoryDao;
import babymall.dao.IProductDao;

@Service
public class CategoryServiceImpl implements ICategoryService {
	
	@Resource
	private IProductDao productDao;
	@Resource
	private ICategoryDao categoryDao;

	@Override
	public int del(int id) {
		//如果分类下有商品，删除失败
		if(productDao.getCountByCategoryId(id)>0) {
			return 0;
		}else {
			return categoryDao.del(id);
		}
	}

}
